﻿// *************************************************************************************************
// Project: RealSense.Light.Core
// Namespace: RealSense.Light.Core
// File: SpeechSynthesisDevices.cs  Author: Peter O'Hanlon
// Copyright © Peter O'Hanlon 2014-2015
// Date: 2015/2/9 07:44
// *************************************************************************************************
using RealSense.Light.CodeContracts;
using RealSense.Light.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealSense.Light.Core
{
  public class SpeechSynthesisDevices : RealSenseBase, ISpeechSynthesisDevices
  {
    public IEnumerable<string> GetDevices()
    {
      List<string> devices = new List<string>();

      PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
      desc.cuids[0] = PXCMSpeechSynthesis.CUID;

      bool success = true;
      int index = 0;
      while(success)
      {
        PXCMSession.ImplDesc desc1 = null;
        success = Invoke(() => SenseManager.SenseManager.session.QueryImpl(desc, index++, out desc1), 
          "retrieving speech synthesis device details.");
        if (success && desc1 != null)
        {
          devices.Add(desc1.friendlyName);
        }
      }

      return devices;
    }

    protected override void Dispose(bool disposing)
    {
      // No-op dispose.
    }
  }
}
